/* GUI CONVERTED from rspsmt.p (converter v1.75) Sat Aug 12 23:15:04 2000 */
/* rspsmt.p - Supplier Planning Schedules                                */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                   */
/* All rights reserved worldwide.  This is an unpublished work.          */
/*V8:ConvertMode=Maintenance                                             */
/*V8:RunMode=Character,Windows                                           */
/* REVISION: 9.0    CREATED       : 05/19/98 BY: *K1QZ* Suresh Nayak     */
/* REVISION: 9.0    LAST MODIFIED : 01/06/99 BY: *M04G* Steve Nugent     */
/* REVISION: 9.0    LAST MODIFIED : 03/13/99 BY: *M0BD* Alfred Tan       */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00 BY: *N0KP* myb              */


/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */
/*         THIS PROGRAM IS A BOLT-ON TO STANDARD PRODUCT MFG/PRO.           */
/* ANY CHANGES TO THIS PROGRAM MUST BE PLACED ON A SEPARATE ECO THAN        */
/* STANDARD PRODUCT CHANGES.  FAILURE TO DO THIS CAUSES THE BOLT-ON CODE TO */
/* BE COMBINED WITH STANDARD PRODUCT AND RESULTS IN PATCH DELIVERY FAILURES.*/
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */

         /*DISPLAY TITLE */
         {mfdtitle.i "b+ "}

         /* ********** Begin Translatable Strings Definitions ********* */

              &SCOPED-DEFINE rspsmt_p_1 " Resource Authorization Data "
              /* MaxLen: Comment: */

              &SCOPED-DEFINE rspsmt_p_2 "Comments"
              /* MaxLen: Comment: */

              &SCOPED-DEFINE rspsmt_p_3 "Active Start"
              /* MaxLen: Comment: */

              &SCOPED-DEFINE rspsmt_p_4 "Active End"
              /* MaxLen: Comment: */

         /* ********** End Translatable Strings Definitions ********* */

         define new shared variable cmtindx like cmt_indx.
         define new shared variable global_schtype as integer.

         define variable schtype as integer initial 5 no-undo.
         define variable i as integer no-undo.
         define variable del-yn like mfc_logical no-undo.
         define variable yn like mfc_logical no-undo.
         define variable cmmts like poc_hcmmts label {&rspsmt_p_2} initial yes.
         define variable this_eff_start as date no-undo.
         define variable impexp   like mfc_logical no-undo.
         define variable impexp_label as character no-undo.
         define variable sch_recid as recid no-undo.
         define variable old_db as character no-undo.
         define variable sdb_err as integer no-undo.
         define variable subtype as character no-undo.
         define variable l_old_fab_qty like sch_fab_qty no-undo.
         define variable l_new_fab_qty like sch_fab_qty no-undo.
         define variable l_old_raw_qty like sch_raw_qty no-undo.
         define variable l_new_raw_qty like sch_raw_qty no-undo.
         define variable l_pod_curr_rlse_id like pod_curr_rlse_id[1] no-undo.
         define variable schd_recid as recid no-undo.
         define variable new_schedule as logical initial false no-undo.
         define variable processed_sched as logical no-undo.

         define buffer prev_sch_mstr for sch_mstr.
         define buffer prev_schd_det for schd_det.
         define buffer type_4_sch_mstr for sch_mstr.
         define buffer type_4_schd_det for schd_det.

         define new shared frame a.

         define new shared workfile work_schd like schd_det.

         {rsordfrm.i}

         
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
              space(1)
          sch_rlse_id colon 16
                   skip(.4)   
         with frame a width 80 attr-space THREE-D /*GUI*/.

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



         /* SET EXTERNAL LABELS */
         setFrameLabels(frame a:handle).

         for first poc_ctrl no-lock: end.

         repeat transaction:
/*GUI*/ if global-beam-me-up then undo, leave.


            /* GET SCHEDULED ORDER */
            {rsgetord.i "old"  " "  " "  "validate"}

            /* GET SCHEDULE RECORD */
            {rsgetrel.i}

            /* DO NOT ALLOW MODS TO SCHEDULE IF SCHEDULE ALREADY SENT */
            /* TO SUPPLIER                                            */

            if length(sch_ship) > 16 then do:
               {mfmsg.i 4378 4} /* CANNOT MODIFY, SCHED SENT TO SUPPLIER */
                next-prompt sch_rlse_id with frame a.
                undo, retry.
            end.

            cmmts = poc_hcmmts.
            if sch_cmtindx > 0 then cmmts = yes.

            FORM /*GUI*/ 
                
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
cmmts          colon 20
                sch_cr_date    colon 55
                sch_cr_time    no-label
                sch_pcr_qty    colon 20
                sch_eff_start  colon 55 label {&rspsmt_p_3}
                sch_pcs_date   colon 20
                sch_eff_end    colon 55 label {&rspsmt_p_4}
             SKIP(.4)  /*GUI*/
with frame sched_data attr-space side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-sched_data-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame sched_data = F-sched_data-title.
 RECT-FRAME-LABEL:HIDDEN in frame sched_data = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame sched_data =
  FRAME sched_data:HEIGHT-PIXELS - RECT-FRAME:Y in frame sched_data - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME sched_data = FRAME sched_data:WIDTH-CHARS - .5.  /*GUI*/


            /* SET EXTERNAL LABELS */
            setFrameLabels(frame sched_data:handle).

            display sch_cr_date
                string(sch_cr_time,"HH:MM:SS") format "x(8)" @ sch_cr_time
            with frame sched_data.

            ststatus = stline[2].
            status input ststatus.

            display
                cmmts
                sch_pcr_qty
                sch_pcs_date
                sch_eff_start
                sch_eff_end
            with frame sched_data.

            do on error undo , retry:
/*GUI*/ if global-beam-me-up then undo, leave.

               set
                  cmmts
                  sch_pcr_qty
                  sch_pcs_date
                  sch_eff_start
                  sch_eff_end
               go-on(F5 CTRL-D) with frame sched_data.

               if lastkey = keycode("F5") or lastkey = keycode("CTRL-D")
               then do:

              /* WARN THE USER WHEN A CONTAINER/SHIPPER IS FOUND FOR THE
               * PURCHASE ORDER. */
                 for first scx_ref where
                                    scx_type  = 2        and
                                    scx_order = sch_nbr  and
                                    scx_line  = sch_line
                                    no-lock:
                 end.

                 for first abs_mstr where abs_shipfrom = scx_shipfrom     and
                                          abs_dataset  = "pod_det"        and
                                          abs_order    = sch_nbr          and
                                          abs_line     = string(sch_line)
                                          no-lock:
                 end.
/*GUI*/ if global-beam-me-up then undo, leave.

                 if available abs_mstr then do:
                    /* SHIPPER OR CONTAINER EXISTS FOR SCHEDULE LINE */
                    {mfmsg.i 8304 2}
                 end. /* END OF IF AVAILABLE abs_mstr */

                  del-yn = no.
                  {mfmsg01.i 11 1 del-yn}
                  if del-yn = no then undo, retry.

                  if pod_curr_rlse_id[schtype - 3] = sch_rlse_id then
                  pod_curr_rlse_id[schtype - 3] = "".

                  {gprun.i ""rcschdel.p"" "(input recid(sch_mstr), input no)"}
/*GUI*/ if global-beam-me-up then undo, leave.


                  clear frame sched_data.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame sched_data = F-sched_data-title.
                  clear frame a.
                  next.
               end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* END OF IF LASTKEY = KEYCODE(F5)  */

               if sch_pcs_date = ? then do:
                  {mfmsg.i 8240 3} /* INVALID PRIOR CUM START DATE */
                  next-prompt sch_pcs_date with frame sched_data.
                  undo , retry.
               end. /* END OF IF sch_pcs_date = ? */

               if new sch_mstr then do:
                      new_schedule = yes.
               end.
               else do:
                      new_schedule = no.
               end.

               if new sch_mstr and sch_eff_start < today then do:
                  {mfmsg.i 27 3} /* INVALID DATE */
                  next-prompt sch_eff_start with frame sched_data.
                  undo , retry.
               end. /* END OF IF new sch_mstr and sch_eff_date < TODAY */

               if sch_eff_end < sch_eff_start then do:
                  {mfmsg.i 4 3} /* START DATE MUST BE PRIOR TO END DATE */
                  next-prompt sch_eff_start with frame sched_data.
                  undo, retry.
               end. /* END OF IF sch_eff_end < sch_eff_start */
            end. /* END OF DO ON ERROR UNDO, RETRY */

            if cmmts then do:
               cmtindx = sch_cmtindx.
               global_ref = po_vend.
               {gprun.i ""gpcmmt01.p"" "(input ""po_mstr"")"}
/*GUI*/ if global-beam-me-up then undo, leave.

               sch_cmtindx = cmtindx.
               view frame a.
            end. /* END OF IF cmmts */

            view frame a.

            hide frame sched_data.

            /* DO DETAIL MAINTENANCE */
            {gprun.i ""rspsmtb.p"" "(input recid(sch_mstr),
                                     output schd_recid)"}
/*GUI*/ if global-beam-me-up then undo, leave.


            /* AUTHORIZATIONS */
            FORM /*GUI*/ 
                
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
sch_fab_qty       colon 15
                sch_fab_strt        colon 40   
                sch_fab_end         colon 60   
                sch_raw_qty       colon 15
                sch_raw_strt        colon 40   
                sch_raw_end         colon 60   
             SKIP(.4)  /*GUI*/
with frame res_auth_data width 80
            
            attr-space side-labels NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-res_auth_data-title AS CHARACTER.
 F-res_auth_data-title = (getFrameTitle("RESOURCE_AUTHORIZATION_DATA",38)).
 RECT-FRAME-LABEL:SCREEN-VALUE in frame res_auth_data = F-res_auth_data-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame res_auth_data =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame res_auth_data + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame res_auth_data =
  FRAME res_auth_data:HEIGHT-PIXELS - RECT-FRAME:Y in frame res_auth_data - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME res_auth_data = FRAME res_auth_data:WIDTH-CHARS - .5. /*GUI*/


            /* SET EXTERNAL LABELS */
            setFrameLabels(frame res_auth_data:handle).

            if new sch_mstr then do:
               sch_fab_strt = pod_cum_date[1].
               sch_raw_strt = pod_cum_date[1].

               if pod_fab_days > 0 then do:
                  sch_fab_qty = sch_pcr_qty.

                  for each schd_det no-lock
                  where schd_type = sch_type
                  and schd_nbr = sch_nbr
                  and schd_line = sch_line
                  and schd_rlse_id = sch_rlse_id
                  and schd_date <= sch_pcs_date + pod_fab_days:
                     sch_fab_qty = sch_fab_qty + schd_discr_qty.
                     sch_fab_end = schd_date.
                  end. /* END OF FOR EACH schd_det */
               end. /* END OF IF pod_fab_days > 0 */

               if pod_raw_days > 0 then do:
                  sch_raw_qty = sch_pcr_qty.

                  for each schd_det no-lock
                  where schd_type = sch_type
                  and schd_nbr = sch_nbr
                  and schd_line = sch_line
                  and schd_rlse_id = sch_rlse_id
                  and schd_date <= sch_pcs_date + pod_raw_days:
                     sch_raw_qty = sch_raw_qty + schd_discr_qty.
                     sch_raw_end = schd_date.
                  end. /* END OF FOR EACH schd_det */
               end. /* END OF IF pod_raw_days > 0 */
            end. /* END OF IF new_sch_mstr */

            ststatus = stline[3].
            status input ststatus.

            assign
               l_old_fab_qty = sch_fab_qty
               l_old_raw_qty = sch_raw_qty
               .

            do on endkey undo , leave:
               update
                   sch_fab_qty
                   sch_fab_strt
                   sch_fab_end
                   sch_raw_qty
                   sch_raw_strt
                   sch_raw_end
               with frame res_auth_data.

               assign
                  l_new_fab_qty = sch_fab_qty
                  l_new_raw_qty = sch_raw_qty
                  .

               run fab_raw_update (input recid(sch_mstr),
                                   input pod_curr_rlse_id[2],
                                   input l_old_fab_qty,
                                   input l_new_fab_qty,
                                   input l_old_raw_qty,
                                   input l_new_raw_qty
                                  ).

            end. /* END OF DO ON ENDKEY UNDO, LEAVE */

            hide frame res_auth_data.

            yn = no.
            if sch_rlse_id <> pod_curr_rlse_id[schtype - 3] then do:
               {mfmsg01.i 6001 1 yn} /* MAKE THIS SCHEDULE ACTIVE? */

               if yn then do:
                  assign
                      this_eff_start = sch_eff_start
                      sch_recid = recid(sch_mstr).

                  for first sch_mstr where sch_type = schtype
                  and sch_nbr = pod_nbr
                  and sch_line = pod_line
                  and sch_rlse_id = pod_curr_rlse_id[schtype - 3]
                  exclusive-lock: end.

                  if available sch_mstr then
                  assign sch_eff_end = this_eff_start.

                  for first sch_mstr where recid(sch_mstr) = sch_recid
                  exclusive-lock: end.

                  assign
                      sch_eff_end = ?
                      pod_curr_rlse_id[schtype - 3] = sch_rlse_id.

                 /* SET POD_CURR_RLSE_ID IN REMOTE DB TOO */
                 if available po_mstr then
                    for first si_mstr where si_site = po_site
                    no-lock: end.
                 else
                    for first si_mstr where si_site = pod_po_site
                    no-lock: end.

                 if available si_mstr then do:
                    if si_db <> global_db then do:
                       old_db = global_db.
                       {gprun.i ""gpalias3.p"" "(input si_db, output sdb_err)"}
/*GUI*/ if global-beam-me-up then undo, leave.

                       {gprun.i ""rssmt01.p"" "(input scx_po, input scx_line,
                        input sch_rlse_id, input schtype)"}
/*GUI*/ if global-beam-me-up then undo, leave.

                       {gprun.i ""gpalias3.p"" "(input old_db, output sdb_err)"}
/*GUI*/ if global-beam-me-up then undo, leave.

                    end. /* END OF IF si_db <> global_db */
                 end. /* END OF IF AVAILABLE si_mstr */
               end. /* END OF IF yn */
            end. /* END OF IF sch_rlse_id <> pod_curr_rlse_id[schtype - 3] */

            /* IF THIS IS A NEW PLANNING SCHEDULE (TYPE 5) THEN WE NEED TO
               CREATE A TYPE 4 SCHEDULE EQUIVALENT TO THE TYPE 5. THIS IS
               NEEDED BECAUSE MRP ONLY LOOKS AT TYPE 4 SCHEDULE FOR
               REQUIREMENTS. SO IN ORDER FOR MRP TO SEE THESE REQUIREMENTS
               A TYPE 4 SCHEDULE FOR THE NEW TYPE 5 NEEDS TO BE CREATED */

           processed_sched = no.

           if new_schedule then do:

              run sched_4_lookup (input recid(sch_mstr),
                                  input recid(schd_det),
                                  output processed_sched).

              if not processed_sched then do:

                 create type_4_sch_mstr.

                   assign
                     type_4_sch_mstr.sch_type = 4
                     type_4_sch_mstr.sch_nbr = sch_mstr.sch_nbr
                     type_4_sch_mstr.sch_line = sch_mstr.sch_line
                     type_4_sch_mstr.sch_rlse_id = sch_mstr.sch_rlse_id
                     type_4_sch_mstr.sch_cr_date = today
                     type_4_sch_mstr.sch_cr_time = time
                     type_4_sch_mstr.sch_eff_start = sch_mstr.sch_eff_start
                     type_4_sch_mstr.sch_cumulative = sch_mstr.sch_cumulative
                     type_4_sch_mstr.sch_fab_qty = sch_mstr.sch_fab_qty
                     type_4_sch_mstr.sch_fab_end = sch_mstr.sch_fab_end
                     type_4_sch_mstr.sch_fab_strt = sch_mstr.sch_fab_strt
                     type_4_sch_mstr.sch_pcr_qty = sch_mstr.sch_pcr_qty
                     type_4_sch_mstr.sch_pcs_date = sch_mstr.sch_pcs_date
                     type_4_sch_mstr.sch_raw_qty = sch_mstr.sch_raw_qty
                     type_4_sch_mstr.sch_raw_strt = sch_mstr.sch_raw_strt
                     type_4_sch_mstr.sch_raw_end = sch_mstr.sch_raw_end
                     type_4_sch_mstr.sch_sd_pat = sch_mstr.sch_sd_pat
                     type_4_sch_mstr.sch_sd_time = sch_mstr.sch_sd_time
                     .

                     if recid(type_4_sch_mstr) = -1 then .

                 assign
                      pod_curr_rlse_id[1] = type_4_sch_mstr.sch_rlse_id.

               for first schd_det where recid(schd_det) = schd_recid
               no-lock: end.

               if available schd_det then do:

                  for each schd_det no-lock
                           where
                           schd_type = 5                           and
                           schd_line = type_4_sch_mstr.sch_line    and
                           schd_nbr = type_4_sch_mstr.sch_nbr      and
                           schd_rlse_id = type_4_sch_mstr.sch_rlse_id
                           break by schd_date
                                 by schd_time
                                 by schd_reference:

                                   accumulate schd_discr_qty
                                   (sub-total by schd_reference).

                             if last-of(schd_reference) then do:

                                create type_4_schd_det.

                                   assign

                                     type_4_schd_det.schd_type = 4
                                     type_4_schd_det.schd_nbr =
                                            schd_det.schd_nbr
                                     type_4_schd_det.schd_line =
                                            schd_det.schd_line
                                     type_4_schd_det.schd_rlse_id =
                                            schd_det.schd_rlse_id
                                     type_4_schd_det.schd_date =
                                            schd_det.schd_date
                                     type_4_schd_det.schd_time =
                                            schd_det.schd_time
                                     type_4_schd_det.schd_interval =
                                            schd_det.schd_interval
                                     type_4_schd_det.schd_reference =
                                            schd_det.schd_reference
                                     type_4_schd_det.schd_discr_qty =
                                            accum sub-total by
                                                schd_det.schd_reference
                                                schd_det.schd_discr_qty
                                     type_4_schd_det.schd_fc_qual =
                                            schd_det.schd_fc_qual.

                                     if recid(type_4_schd_det) = -1 then .

                               end. /* if last-of */
                    end. /* for each schd_det */
                 end. /* if available schd_det */
              end. /* if not processed_sched */
           end. /* if new_schedule */

         end. /* END OF REPEAT TRANSACTION */

         PROCEDURE fab_raw_update:

         define input parameter sch_recid as recid no-undo.
         define input parameter l_pod_curr_rlse_id
                           like l_pod_curr_rlse_id[2] no-undo.
         define input parameter l_old_fab_qty like sch_fab_qty no-undo.
         define input parameter l_new_fab_qty like sch_fab_qty no-undo.
         define input parameter l_old_raw_qty like sch_raw_qty no-undo.
         define input parameter l_new_raw_qty like sch_raw_qty no-undo.
         define buffer b_sch_mstr for sch_mstr.
         define buffer b_sch_mstr2 for sch_mstr.

         for first b_sch_mstr where recid(b_sch_mstr) = sch_recid
         no-lock: end.

               for first b_sch_mstr2 where
                   b_sch_mstr2.sch_type = 4                   and
                   b_sch_mstr2.sch_nbr = b_sch_mstr.sch_nbr   and
                   b_sch_mstr2.sch_line = b_sch_mstr.sch_line and
                   b_sch_mstr2.sch_rlse_id = b_sch_mstr.sch_rlse_id
                   exclusive-lock:
               end.

                  if available b_sch_mstr2 then do:

                     if l_old_fab_qty <> l_new_fab_qty then do:
                          b_sch_mstr2.sch_fab_qty = l_new_fab_qty.
                     end.

                     if l_old_raw_qty <> l_new_raw_qty then do:
                          b_sch_mstr2.sch_raw_qty = l_new_raw_qty.
                     end.
                  end. /* if available sch_mstr */

         END PROCEDURE. /* END PROCEDURE fab_raw_update */

         PROCEDURE sched_4_lookup:

         define input parameter sch_recid as recid no-undo.
         define input parameter schd_recid as recid no-undo.
         define output parameter processed_sched as logical no-undo.

         define buffer type_4_sch_mstr for sch_mstr.
         define buffer type_4_schd_det for schd_det.

         for first sch_mstr where recid(sch_mstr) = sch_recid no-lock:
         end.

         for first schd_det where recid(schd_det) = schd_recid no-lock:
         end.

         for first type_4_sch_mstr where
                   type_4_sch_mstr.sch_type = 4                    and
                   type_4_sch_mstr.sch_nbr = sch_mstr.sch_nbr      and
                   type_4_sch_mstr.sch_line = sch_mstr.sch_line    and
                   type_4_sch_mstr.sch_rlse_id = sch_mstr.sch_rlse_id
                   exclusive-lock:
         end.

            if available type_4_sch_mstr then do:

               assign
                 type_4_sch_mstr.sch_fab_end = sch_mstr.sch_fab_end
                 type_4_sch_mstr.sch_fab_strt = sch_mstr.sch_fab_strt
                 type_4_sch_mstr.sch_fab_qty = sch_mstr.sch_fab_qty
                 type_4_sch_mstr.sch_raw_end = sch_mstr.sch_raw_end
                 type_4_sch_mstr.sch_raw_strt = sch_mstr.sch_raw_strt
                 type_4_sch_mstr.sch_raw_qty = sch_mstr.sch_raw_qty
                 .

                for each schd_det where
                         schd_type = 5    and
                         schd_nbr = type_4_sch_mstr.sch_nbr     and
                         schd_line = type_4_sch_mstr.sch_line   and
                         schd_rlse_id = type_4_sch_mstr.sch_rlse_id
                         no-lock:

                         for first type_4_schd_det where
                           type_4_schd_det.schd_type = 4                  and
                           type_4_schd_det.schd_nbr = schd_det.schd_nbr   and
                           type_4_schd_det.schd_line = schd_det.schd_line and
                           type_4_schd_det.schd_rlse_id =
                                  schd_det.schd_rlse_id                   and
                           type_4_schd_det.schd_date = schd_det.schd_date and
                           type_4_schd_det.schd_time = schd_det.schd_time and
                           type_4_schd_det.schd_interval =
                                  schd_det.schd_interval                  and
                           type_4_schd_det.schd_reference =
                                  schd_det.schd_reference
                           exclusive-lock: end.

                           if available type_4_schd_det then do:
                             assign
                              type_4_schd_det.schd_discr_qty =
                                     schd_det.schd_discr_qty
                              type_4_schd_det.schd_fc_qual =
                                     schd_det.schd_fc_qual
/*M04G**                      processed_sched = yes. */
                              .
                           end.
                           else do:
                             create type_4_schd_det.

                               assign
                                type_4_schd_det.schd_type = 4
                                type_4_schd_det.schd_nbr = schd_det.schd_nbr
                                type_4_schd_det.schd_line = schd_det.schd_line
                                type_4_schd_det.schd_rlse_id =
                                       schd_det.schd_rlse_id
                                type_4_schd_det.schd_date = schd_det.schd_date
                                type_4_schd_det.schd_time = schd_det.schd_time
                                type_4_schd_det.schd_interval =
                                       schd_det.schd_interval
                                type_4_schd_det.schd_reference =
                                       schd_det.schd_reference
                                type_4_schd_det.schd_discr_qty =
                                       schd_det.schd_discr_qty
                                type_4_schd_det.schd_fc_qual =
                                       schd_det.schd_fc_qual
                                .

                                if recid(type_4_schd_det) = -1 then .

/*M04G**                        processed_sched = yes.  */

                           end. /* else do: */
                end. /* for each schd_det */
/*M04G*/        processed_sched = yes.
            end. /* if available type_4_sch_mstr */
            else do:
              processed_sched = no.
            end. /* else do: */
         END PROCEDURE. /* END PROCEDURE sched_4_lookup  */
